#ifndef QSHORTCUTPROPERTYEDITOR_H
#define QSHORTCUTPROPERTYEDITOR_H

#include "QtPropertyExplorerLib.h"

#include <QWidget>
#include <QToolButton>
#include <QLineEdit>
#include <QMimeData>

namespace QPE{


class QTPROPERTYEXPLORER_DLL_EXPORT QShortcutEditWidget : public QWidget
{
	Q_OBJECT

public:
	QShortcutEditWidget(QWidget* parent);
	virtual ~QShortcutEditWidget();

	//! Needed for proper event handling
	bool eventFilter(QObject* obj, QEvent* evenvt);

	//! Returns the currently set shortcut
	QString getShortcutAsString();

	//! Returns the currently set shortcut
	QKeySequence getShortcut();

signals:
	//! This signal is emitted when the user changed the current shortcut
	void dataChangedByUser(const QKeySequence& sequence, QShortcutEditWidget* editor);

	//! This signal is emitted whenever dataChangedByUser() gets emmitted
	//! and is connected to the delegate's commitData() signal
	void commitData(QWidget* editor);

public slots:
	//! Sets the shortcut
	//! \param shortcut The new shortcut
	//! \emit_signal If true, this will emit the dataChangedByUser()-signal
	void setShortcut(const QString &shortcut, bool emit_signal);

	//! Sets the shortcut
	//! \param shortcut The new shortcut
	//! \emit_signal If true, this will emit the dataChangedByUser()-signal
	void setShortcut(const QKeySequence &shortcut, bool emit_signal);

private slots:
	//! This slot is called when the user edits the line edit (e.g. by removing or pasting text using the mouse)
	void onTextEdited(const QString& text);

protected:
	//! The current key sequence
	QKeySequence CurrentKeySequence;

	//! The line to display and edit the key sequence
	QLineEdit* LineEdit;
};

}

#endif // QFILEPROPERTYEDITOR_H
